<?php
define('BOOK_WEB','books');
require_once 'common.php';
require_once 'page.php';
$sql="select * from books";
$book_name=isset($_GET['book_name'])?trim($_GET['book_name']):'';
$page=isset($_GET['page'])?$_GET['page']:1;
$pagesize=5;
if($book_name){
    $sql="select * from books where name like '%".$book_name."%'";
}
if($page){
    $sql.=make_page($page,$pagesize);
}
$result=$pdo->query($sql);
$number=$pdo->query('select * from books')->rowCount();
$books=$result->fetchAll();
$maxpage=ceil($number/$pagesize);
include_once 'list.html';